package com.qf.service.impl;

import cn.hutool.crypto.SecureUtil;
import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import com.qf.entity.User;
import com.qf.service.UserService;

/**
 * --- 天道酬勤 ---
 *
 * @author Hulboy
 * @date 2024/6/30
 * @desc --- 代码敲烂 月薪过万 ---
 */
public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();

    @Override
    public User login(String username, String password) {
        String s = SecureUtil.md5(password);
        User user = userDao.login(username, s);
        return user;
    }

    @Override
    public boolean regist(User user) {
        //业务处理-对密码加密
        String password = user.getPassword();   //接收user密码
        String s = SecureUtil.md5(password);    //加密为s
        user.setPassword(s);                    //User对象密码修改为加密后的s

        boolean isok = userDao.regist(user);    //给Dao类执行
        return isok;         // regist调用的，所以布尔值返回给regist

    }
}
